package com.smtx.test;

import org.springframework.core.task.TaskExecutor;
import org.springframework.integration.channel.ExecutorChannel;

/**
 * Created by IntelliJ IDEA.
 * User: Cyril
 * Date: 21.05.11
 * Time: 23:10
 * To change this template use File | Settings | File Templates.
 */
public class TaskExecutorExample {
    private class MessagePrinterTask implements Runnable {
        private String message;

        public MessagePrinterTask(String message) {
            this.message = message;
        }

        public void run() {
            System.out.println(message);
        }
    }

    private TaskExecutor taskExecutor;

    public TaskExecutorExample(TaskExecutor taskExecutor) {
        this.taskExecutor = taskExecutor;
    }

    public Boolean printMessages() {
        for (int i = 0; i < 25; i++) {
            taskExecutor.execute(new MessagePrinterTask("Message" + i));
        }
        return Boolean.TRUE;
    }
}
